package com.space.rbq.store.service.impl;

import com.space.rbq.store.bean.Order;
import com.space.rbq.store.service.StoreService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Random;

/**
 * @author zhuzhe
 * @date 2018/6/7 10:14
 * @email 1529949535@qq.com
 */
@Transactional(readOnly = true)
@Service
public class StoreServiceImpl implements StoreService{
    Random rand =new Random(2);

    @Transactional
    @Override
    public int update(Order order) {

        int i;
        i=rand.nextInt(2);
        return 2/i;
    }

    public static void main(String[] args) {

        // 案例2
        // 对于种子相同的Random对象，生成的随机数序列是一样的。
        Random ran1 = new Random(2);
        System.out.println("使用种子为10的Random对象生成[0,10)内随机整数序列: ");
        for (int i = 0; i < 10; i++) {
            System.out.print(ran1.nextInt(2) + " ");
        }
    }
}
